<html>
	<head>
	    <title>Letta Teknoloji Yonetim Paneli</title>
		<meta content="text/html; charset=utf-8" http-equiv="content-type" />
		<META http-equiv="content-type" content="text/html;charset=iso-8859-9">
		<META http-equiv="content-type" content="text/html;charset=windows-1254">
		<META http-equiv="content-type" content="text/html;charset=x-mac-turkish">
		<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
		<script type="text/javascript" src="js/ckeditor/ckeditor.js"></script>
		<script type="text/javascript" src="js/ckeditor/adapters/jquery.js"></script>
		<script src="js/ckeditor/sample.js" type="text/javascript"></script>
		<link href="css/sample.css" rel="stylesheet" type="text/css" />
		<link type="text/css" href="css/ui/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
		<script type="text/javascript">	
		function load(indeks,edit)
		{
		    var loadData = "stage="+indeks+"&id="+edit;
			$.ajax({url:"select.php",
				  data:loadData,
				  success:function(data)
				  {
				     editLoad(data);
				  },
				  dataType:"text"	
				});
			
		}
		function editLoad(data)
		{		
			var xmlDoc = $.parseXML(data),
				$xml      = $(xmlDoc),
				$title    = $xml.find("title"),
				$baslik   = $xml.find("param1"),
				$aciklama = $xml.find( "param2" ),
				$resim    = $xml.find( "param3" ),
				$govde    = $xml.find( "param5" );
				$ustid    = $xml.find( "param6" );
			$("#icerikBaslik").val($baslik.text());
			$("#icerikAciklama").val($aciklama.text());
			$("#icerikResim").val($resim.text());
			$("#editor1").val($govde.text());
		}
		//<![CDATA[
			$(function()
			{
				var config = {
					toolbar:
					[
						['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink'],
						['UIColor']
					]
				};

				// Initialize the editor.
				// Callback function can be passed and executed after full instance creation.
				$('.jquery_ckeditor').ckeditor(config);
			});
		//]]>
		</script>
		<script type="text/javascript">
			var ustID = 0;
			$(function(){
				$('#tabs').tabs();
            });
			function init(data)
			{
				section(data);
			}
			function kaydet(giris)
			{
				ustID = $('select[name=combobox] option:selected').val();
				$datas = "editor1="+$("#editor1").val()
				+"&icerikBaslik="+$("#icerikBaslik").val()
				+"&icerikAciklama="+$("#icerikAciklama").val()
				+"&icerikResim="+$("#icerikResim").val()
				+"&sayfa="+giris
				+"&ust="+ustID
				+"&kucukResim="+$("#kucukResim").val();
				$.post("veriEkle2.php",$datas,
					function(data)
					{
						if(data.length == 0)
						{
							 alert("Basaryla Kaydettinz!");
							 $("#resimForm").submit();
						}
					}
				);
			}
		</script>
		<script type="text/javascript">
		    var veri = "0";
			
		    function sayfaSecim(index)
			{
                window.location = "index.php?stage="+index;
			}
			$(function() {
				$( "#anasayfa").button({
				});
				$( "#sayfalar").button({
				});
				$( "#urunler").button({
				});
				$( "#haberler").button({
				});
				$( "#ayarlar").button({
				});
				$( "#cikis").button({
				});
				$( "#insert" )
				.button({
					icons: {
					primary: "ui-icon-plus"
					},
					text: true,
			    })
				.click(function(){
				    section(1);
				});
				$( "#list" ).button({
					icons: {
					primary: "ui-icon-note"
					},
					text: true
			    })
				.click(function(){
				    section(0);
				});
				$( "#kaydet" ).button({
					icons: {
					primary: "ui-icon-disk"
					},
					text: true
			    });
			});
			function section(data)
			{
				if(data == 0)
				{
					$("#listeTema").css("visibility","hidden");
					$("#tema").css("visibility","visible");
					
				}
				if(data == 1)
				{
					$("#listeTema").css("visibility","visible");
					$("#tema").css("visibility","hidden");
					
				}
			}
	    </script>

        <style type="text/css">
			body{ font: 62.5% "Trebuchet MS", sans-serif; margin: 50px;}
			.demoHeaders { margin-top: 2em; }
			#dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
			#dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
			ul#icons {margin: 0; padding: 0;}
			ul#icons li {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left;  list-style: none;}
			ul#icons span.ui-icon {float: left; margin: 0 4px;}
			.demo{top:20px;position:absolute;}
			#toolbar {padding: 10px 4px;}
			#tabs{width:65%;position:absolute;top:20%}
			#insert{margin-left:55%;}
			#baslik{position:absolute;margin-top:2px;margin-bottom:2px;}
			#sag-menu{position:absolute;margin-left:67%;top:20%;width:20%;height:50%;}
			.sutun1{width:150px;}
			.girisler{width:800px;}
			div#users-contain { width: 1050px; margin: 20px 0; }
			div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
			div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
            label, input { display:block; }
			fieldset { padding:0; border:0; margin-top:25px; }
			.konuBaslik{margin-top:-5px;}
			h1{margin-top:-50px;};
		</style>
	</head>
	
	<?php 
	    $loadIndex = $_GET['stage'];
		$loadedit  = $_GET['edit'];
		echo "<body onLoad=\"load(".$loadIndex.",".$loadedit.");\">";
    ?>

    <div class="demo">
		<span id="toolbar" class="ui-widget-header ui-corner-all">
			<button id="anasayfa">AnaSayfa</button>
			<button id="sayfalar" onClick="sayfaSecim(1);">Sayfalar</button>
			<button id="haberler" onClick="sayfaSecim(2);">Haberler</button>
			<button id="cikis">Cikis</button>
		</span>
    </div>
	<hr/>
	<?php
	    
		$sayfaBilgi = array(
							array("sayfaAdi"=>"sayfa","sayfaEkleme"=>"Sayfa Ekle","sayfaListeleme"=>"Sayfa Listesi"),
							array("sayfaAdi"=>"haber","sayfaEkleme"=>"Haber Ekle","sayfaListeleme"=>"Haber Listesi")
							);
	    $turler = array("anasayfa","veri","haber");
        if(!empty($_GET['stage']))
	    {
		    $indeks = $_GET['stage'];
			echo "<div id=\"insert\">";
				echo "<a href=\"?stage=".$indeks."&section=0\"><span id=\"insertLabel\">".$sayfaBilgi[$indeks-1]["sayfaEkleme"]."</span></a>";
			echo "</div>";
			echo "<div id=\"list\">";
				echo "<a href=\"?stage=".$indeks."&section=1\"><span id=\"listLabel\">".$sayfaBilgi[$indeks-1]["sayfaListeleme"]."</span></a>";
			echo "</div>";
			
		}
	    echo "<div id=\"tema\" style=\"visibility:hidden;\">";
		echo "<h1 class=\"konuBaslik\">".$sayfaBilgi[$indeks-1]["sayfaEkleme"]."</h1>";
		
		?>		
		<div id="tabs">
				<ul>
					<li><a href="#tabs-1">Turkce</a></li>
					<li><a href="#tabs-2">Ingilizce</a></li>
				</ul>
				<div id="tabs-1">
						<table class="girisler">

							<tr>
								<td class="sutun1" id="baslikEtiketi">Baslik</td>
								<td><input type="text" name="icerikBaslik" id="icerikBaslik" style="width:65%;"></input></td>
									<?php
									    $link = mysql_connect("localhost","turker","20041987","letta");
										mysql_select_db("letta",$link);
									    if($_GET['stage'] == 1 )
										{
											$queryString = "SELECT * FROM veri WHERE aktif=1 AND ustid !=-1";
											$komut = mysql_query($queryString) or die(mysql_error());
											echo "<td>
												<select name=\"combobox\" name=\"ust\">"; 
												while($value = mysql_fetch_array($komut))
												{
													echo "<option value=\"$value[0]\">".$value[1]."</option>";
												}
											echo "</select> 
										   </td>";
										}	
									?>
									
							</tr>
							<tr>
								<td class="sutun1" id="aciklamaEtiketi">Aciklama</td>
								<td><input type="text" name="icerikAciklama" id="icerikAciklama" style="width:95%;"></input></td>
							</tr>
							<tr>
								
								<td class="sutun1" id="resimEtiketi">Resim</td>
				                <td>
					<form id="resimForm" action=<?php echo "index.php?stage=".$_GET['stage']."&section=1";?> enctype="multipart/form-data" method="post">
								<input type="file" name="icerikResim" id="icerikResim" />
								<div>
								<?php
								 if(isset($_FILES['icerikResim']['name']))
								 {
									$dosya  = basename($_FILES['icerikResim']['name']);
									$dosya2 = basename($_FILES['kucukResim']['name']);
									
									move_uploaded_file($_FILES['icerikResim']['tmp_name'], '../lettaweb/image/' . $dosya);
									move_uploaded_file($_FILES['kucukResim']['tmp_name'], '../lettaweb/image/' . $dosya2);
								 }
								 if(isset($_FILES['contentImage']['name']))
								 {
									$file  = basename($_FILES['contentImage']['name']);
									$file2 = basename($_FILES['thumb']['name']);
									
									move_uploaded_file($_FILES['contentImage']['tmp_name'], '../lettaweb/image/' . $file);
									move_uploaded_file($_FILES['thumb']['tmp_name'], '../lettaweb/image/' . $file2);
								 }
								?>
								</div>
								</td>
							</tr>
							<tr>
								<td class="sutun1" id="kucukEtiket">Kucuk Resim</td>
								<td>
									<input type="file" id="kucukResim" name="kucukResim" />
								</td>
							</tr>
						</table>
						<textarea class="jquery_ckeditor" cols="80" id="editor1" name="editor1" rows="10"></textarea>
				</div>
				<div id="tabs-2">
					<table class="girisler">
						<tr>
							<td class="sutun1" id="headerLabel">Header</td>
							<td><input type="text" name="contentHeader" style="width:65%;"></input></td>
						</tr>
						<tr>
							<td class="sutun1" id="descriptionLabel">Description</td>
							<td><input type="text" name="contentDescription"style="width:95%;"></input></td>
						</tr>
						<tr>
							<td class="sutun1" id="imageLabel">Image</td>
							<td><input type="file" name="contentImage"style="width:85%;"></input></td>
						</tr>
						<tr>
								<td class="sutun1" id="littleImage">Thumbnail</td>
								<td>
									<input type="file" id="thumb" name="thumb" />
								</td>
							</tr>
					</table>
					<textarea class="jquery_ckeditor" cols="80" id="editor2" name="editor2" rows="10"></textarea>
				</div>

             </form>
			</div>

		<div id="sag-menu"  class= "ui-widget-content ui-corner-all">
			<div class="ui-widget-header ui-corner-all" style="margin-top:1px;">&nbsp;<br/>&nbsp;</div><br/>
			<span style="font-size:12;margin-left:5px;">Icerigi Kaydet:</span><button id="kaydet" style="margin-left:15px" onClick="kaydet(<?php
			echo $_GET['stage'];
			?>);">Kaydet</button>
			<br>
			<br>
			<ul id="icons" class="ui-widget ui-helper-clearfix">
				<li class="ui-state-default ui-corner-all">
					Anahtar Kelimeler
					<span class="ui-icon ui-icon-tag" style="font-size:12;margin-left:5px;"></span>
				</li>		
			</ul>
			<textarea rows="10" style="width:90%;margin-left:5px;"></textarea>
		</div>
    </div>
     <div id="listeTema">
			<div id="users-contain" class="ui-widget">
				<?php
					echo "<h1>".$sayfaBilgi[$indeks-1]["sayfaListeleme"]."</h1>";
				?>
				<table id="users" class="ui-widget ui-widget-content">
					<thead>
						<tr class="ui-widget-header ">
							<th>Durum</th>
							<th>ID#</th>
							<th>Icerik</th>
							<th style="width:300px;">Aciklama</th>
							<th>Ust Oge</th>
							<th>Duzenle</th>
							<th>Goster</th>
							<th>Gizle</th>
							
						</tr>
					</thead>
					<tbody>
					<?php
						   include_once("../letta/db/lettaSql.php");
						   $sql   = new veritabani("localhost","turker","20041987","letta");
						   if(!empty($_GET['stage']))
						   {
								$stage = $_GET['stage'];
								$cumle = "SELECT * FROM ".$turler[$stage]." WHERE ustid > -1";
						        $komut = mysql_query($cumle) or die(mysql_error());
						   }
							while($value = mysql_fetch_array($komut))
							{
										if($value["aktif"] == 1)
										{
											$icon = "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">
												<li class=\"ui-state-default ui-corner-all\">
													<span class=\"ui-icon ui-icon-check\"></span>
												</li>
											</ul>";
										}
										if($value["aktif"] == 0)
										{
											$icon = "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">
												<li class=\"ui-state-default ui-corner-all\">
													<span class=\"ui-icon ui-icon-close\"></span>
												</li>
											</ul>";
										}
									echo "<tr>";
										echo "<td>".$icon."</td>";
										echo "<td>".$value[0]."</td>";
										echo "<td>".$value[1]."</td>";
										echo "<td>".$value[2]."</td>";
										echo "<td>".$value[6]."</td>";
										echo "<td>";
											echo "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
											echo "<li class=\"ui-state-default ui-corner-all\">";
											echo "<a href=\"edit.php?stage=$stage&edit=$value[0]\";><span class=\"ui-icon ui-icon-pencil\" style=\"font-size:12;margin-left:5px;\"></span></a>";
											echo "</li>";		
											echo "</ul>";
										echo "</td>";
								echo "<td>";
									echo "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
										echo "<li class=\"ui-state-default ui-corner-all\">";
											echo "<a href=\"index.php?stage=$stage&view=$value[0]\"><span class=\"ui-icon ui-icon-search\" style=\"font-size:12;margin-left:5px;\"></span></a>";
										echo "</li>";		
									echo "</ul>";
								echo "</td>";
								echo "<td>";
									echo "<ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">";
										echo "<li class=\"ui-state-default ui-corner-all\">";
											echo "<a href=\"index.php?stage=$stage&delete=$value[0]\"><span class=\"ui-icon ui-icon-close\" style=\"font-size:12;margin-left:5px;\"></span></a>";
										echo "</li>";		
									echo "</ul>";
								echo "</td>";
								
							echo "</tr>";
						  }
						if(isset($_GET['delete']) && isset($_GET['stage']) )
						{
								$delete = $_GET['delete'];
								$query1  = "UPDATE veri SET aktif=0 WHERE id=".$delete;										
								mysql_query($query1) or die(mysql_error());
						}
						if(isset($_GET['view']) && isset($_GET['stage']) )
						{
								$view = $_GET['view'];
								$query2  = "UPDATE veri SET aktif=1 WHERE id=".$view;										
								mysql_query($query2) or die(mysql_error());
						}
					?>
					</tbody>
				</table>
			</div>	
	</body>
</html>